﻿using System.Runtime.Serialization;
using System;
using System.Collections.Generic;

namespace RssReaderTemplate.Model
{
    [DataContract]
    public class RssItem : IEquatable<RssItem>
    {
        public RssItem(string title, string content, string author, DateTime publishDate)
        {
            _title = title;
            _content = content;
            _author = author;
            _publishDate = publishDate;
            _categories = new List<string>();
        }

        private Guid _id = Guid.NewGuid();

        [DataMember]
        public Guid Id
        {
            get { return _id; }
            set { _id = value; }
        }

        public override bool Equals(object obj)
        {
            return base.Equals(obj as RssItem);
        }

        public bool Equals(RssItem other)
        {
            return other == null ? false : this.Id == other.Id;
        }

        public override int GetHashCode()
        {
            return this.Id.GetHashCode();
        }

        private string _author;
        [DataMember]
        public string Author
        {
            get { return _author; }
            set { _author = value; }
        }

        private string _title;
        [DataMember]
        public string Title
        {
            get { return _title; }
            set { _title = value; }
        }

        private string _content;
        [DataMember]
        public string Content
        {
            get { return _content; }
            set { _content = value; }
        }

        private DateTime _publishDate;
        [DataMember]
        public DateTime PublishDate
        {
            get { return _publishDate; }
            set { _publishDate = value; }
        }

        private ICollection<string> _categories;
        [DataMember]
        public ICollection<string> Categories
        {
            get { return _categories; }
            set { _categories = value; }
        }





    }
}
